@layout("/common/_container.html"){
<script>
	//下载空白模板
	var xhrDown;
	function downloadModle(index) {
				var fileObj = document.getElementById("file"+index).files[0]; // js 获取文件对象
				if(index==1){
					modelpage="/basemsg";
				}else if(index==2){
					modelpage="/swyreport";
				}else if(index==3){
					modelpage="/indenteruwy";
				}else if(index==4){
					modelpage="/techchange";
				}else if(index==5){
					modelpage="/midwater";
				}else if(index==6){
					modelpage="/halfusewater";
				}
				window.open(Feng.ctxPath + modelpage+ '/dlEmpExcell')
			}
	//图片上传
			var xhr;
			//上传文件方法
			function UpladFile(index) {
				var fileObj = document.getElementById("file"+index).files[0]; // js 获取文件对象
				if(index==1){
					modelpage="/basemsg";
				}else if(index==2){
					modelpage="/swyreport";
				}else if(index==3){
					modelpage="/indenteruwy";
				}else if(index==4){
					modelpage="/techchange";
				}else if(index==5){
					modelpage="/midwater";
				}else if(index==6){
					modelpage="/halfusewater";
				}
				var url =  Feng.ctxPath + modelpage+ '/uploadFile'; // 接收上传文件的后台地址
	
				var form = new FormData(); // FormData 对象
				form.append("file", fileObj); // 文件对象
	
				xhr = new XMLHttpRequest();  // XMLHttpRequest 对象
				xhr.open("post", url, true); //post方式，url为服务器请求地址，true 该参数规定请求是否异步处理。
				xhr.onload = uploadComplete; //请求完成
				xhr.onerror =  uploadFailed; //请求失败

				//xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】
				xhr.upload.onloadstart = function(){//上传开始执行方法
					ot = new Date().getTime();   //设置上传开始时间
					oloaded = 0;//设置上传开始时，以上传的文件大小为0
				};
	
				xhr.send(form); //开始上传，发送form数据
			}
	
			//上传成功响应
			function uploadComplete(evt) {
				//服务断接收完文件返回的结果
				var data = JSON.parse(evt.target.responseText);
				console.log(data)
			
					if(data.code==200){
						Feng.success(data.msg);
					}else{
						Feng.error(data.msg);
					}
				
			}
			//上传失败
			function uploadFailed(evt) {
				Feng.error("上传失败!");
			}
			//取消上传
			function cancleUploadFile(){
				xhr.abort();
			}
			// //上传进度实现方法，上传过程中会频繁调用该方法
			// function progressFunction(evt) {
			// 	var progressBar = document.getElementById("progressBar");
			// 	var percentageDiv = document.getElementById("percentage");
			// 	// event.total是需要传输的总字节，event.loaded是已经传输的字节。如果event.lengthComputable不为真，则event.total等于0
			// 	if (evt.lengthComputable) {//
			// 		progressBar.max = evt.total;
			// 		progressBar.value = evt.loaded;
			// 		percentageDiv.innerHTML = Math.round(evt.loaded / evt.total * 100) + "%";
			// 	}
			// 	var time = document.getElementById("time");
			// 	var nt = new Date().getTime();//获取当前时间
			// 	var pertime = (nt-ot)/1000; //计算出上次调用该方法时到现在的时间差，单位为s
			// 	ot = new Date().getTime(); //重新赋值时间，用于下次计算
			// 	var perload = evt.loaded - oloaded; //计算该分段上传的文件大小，单位b
			// 	oloaded = evt.loaded;//重新赋值已上传文件大小，用以下次计算
			// 	//上传速度计算
			// 	var speed = perload/pertime;//单位b/s
			// 	var bspeed = speed;
			// 	var units = 'b/s';//单位名称
			// 	if(speed/1024>1){
			// 		speed = speed/1024;
			// 		units = 'k/s';
			// 	}
			// 	if(speed/1024>1){
			// 		speed = speed/1024;
			// 		units = 'M/s';
			// 	}
			// 	speed = speed.toFixed(1);
			// 	//剩余时间
			// 	var resttime = ((evt.total-evt.loaded)/bspeed).toFixed(1);
			// 	time.innerHTML = '，速度：'+speed+units+'，剩余时间：'+resttime+'s';
			// 	if(bspeed==0) time.innerHTML = '上传已取消';
			// }
	</script>
<style>
	.upload{
			margin: 30px 30px 0px 0px ;
			float:right;
		}
	</style>
@if(shiro.hasPermission("/basemsg/upload")){
<div class="container-fluid col-sm-4" style="border:1px dashed #999;padding:20px;">
	<h3>上传用水单位基本信息</h3>
	<!-- <progress id="progressBar" value="0" max="100" style="width: 300px;"></progress> -->
	<span id="percentage"></span><span id="time"></span>
	<br />
	<input type="file" id="file1" name="myfile" />
	<br />
	<input class="btn btn-primary" type="button" onclick="UpladFile(1)" value="上传" />
	<input class="btn btn-primary" type="button" onclick="cancleUploadFile(1)" value="删除" />
	<input class="btn btn-primary" type="button" onclick="downloadModle(1)" value="下载空白模板" />
</div>
@}
@if(shiro.hasPermission("/swyreport/upload")){
<div class="container-fluid col-sm-4" style="border:1px dashed #999;padding:20px;">
	<h3>节水量年表</h3>
	<!-- <progress id="progressBar" value="0" max="100" style="width: 300px;"></progress> -->
	<span id="percentage"></span><span id="time"></span>
	<br />
	<input type="file" id="file2" name="myfile" />
	<br />
	<input class="btn btn-primary" type="button" onclick="UpladFile(2)" value="上传" />
	<input class="btn btn-primary" type="button" onclick="cancleUploadFile(2)" value="删除" />
	<input class="btn btn-primary" type="button" onclick="downloadModle(2)" value="下载空白模板" />
</div>
@}
@if(shiro.hasPermission("/indenteruwy/upload")){
<div class="container-fluid col-sm-4" style="border:1px dashed #999;padding:20px;">
	<h3>工业企业行业用水情况年报表</h3>
	<!-- <progress id="progressBar" value="0" max="100" style="width: 300px;"></progress> -->
	<span id="percentage"></span><span id="time"></span>
	<br />
	<input type="file" id="file3" name="myfile" />
	<br />
	<input class="btn btn-primary" type="button" onclick="UpladFile(3)" value="上传" />
	<input class="btn btn-primary" type="button" onclick="cancleUploadFile(3)" value="删除" />
	<input class="btn btn-primary" type="button" onclick="downloadModle(3)" value="下载空白模板" />
</div>
@}
@if(shiro.hasPermission("/techchange/upload")){
<div class="container-fluid col-sm-4" style="border:1px dashed #999;padding:20px;">
	<h3>技改年表</h3>
	<!-- <progress id="progressBar" value="0" max="100" style="width: 300px;"></progress> -->
	<span id="percentage"></span><span id="time"></span>
	<br />
	<input type="file" id="file4" name="myfile" />
	<br />
	<input class="btn btn-primary" type="button" onclick="UpladFile(4)" value="上传" />
	<input class="btn btn-primary" type="button" onclick="cancleUploadFile(4)" value="删除" />
	<input class="btn btn-primary" type="button" onclick="downloadModle(4)" value="下载空白模板" />
	
</div>
@}
@if(shiro.hasPermission("/midwater/upload")){
<div class="container-fluid col-sm-4" style="border:1px dashed #999;padding:20px;">
	<h3>中水</h3>
	<!-- <progress id="progressBar" value="0" max="100" style="width: 300px;"></progress> -->
	<span id="percentage"></span><span id="time"></span>
	<br />
	<input type="file" id="file5" name="myfile" />
	<br />
	<input class="btn btn-primary" type="button" onclick="UpladFile(5)" value="上传" />
	<input class="btn btn-primary" type="button" onclick="cancleUploadFile(5)" value="删除" />
	<input class="btn btn-primary" type="button" onclick="downloadModle(5)" value="下载空白模板" />
</div>
@}
@if(shiro.hasPermission("/halfusewater/upload")){
<div class="container-fluid col-sm-4" style="border:1px dashed #999;padding:20px;">
	<h3>用水单位用水情况半年基础报表</h3>
	<!-- <progress id="progressBar" value="0" max="100" style="width: 300px;"></progress> -->
	<span id="percentage"></span><span id="time"></span>
	<br />
	<input type="file" id="file6" name="myfile" />
	<br />
	<input class="btn btn-primary" type="button" onclick="UpladFile(6)" value="上传" />
	<input class="btn btn-primary" type="button" onclick="cancleUploadFile(6)" value="取消" />
	<input class="btn btn-primary" type="button" onclick="downloadModle(6)" value="下载空白模板" />
</div>
@}

<div style="clear: both;"></div>
<br>
<div style="display:block;"><b>说明：“请上传盖了单位公章并已经填好数据的扫描件”</b></div>
@}